package com.yk.airline.model;

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * Project Name:airlinecrawler
 * File Name:OriginDataModel
 * Package Name:com.yk.airline.model
 * Date:2018/2/1 17:47
 * Author:zhangshaoyang
 * Description:
 * Copyright (c) 2018, 重庆云凯科技有限公司 All Rights Reserved.
 */
@Entity
@Table(name = "origin_data", schema = "cykspider", catalog = "")
public class OriginDataModel {
    private String id;
    private String html;
    private Timestamp createTime;
    private Timestamp updateTime;
    private CaptureWebsiteModel captureWebsiteByCaptureUrl;
    private AirLineModel airLineByAirLine;
    private CaptureMarkModel captureMarkByCaptureMarkId;

    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    @Id
    @Column(name = "id", nullable = false, length = 255)
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "html", nullable = true, length = -1)
    public String getHtml() {
        return html;
    }

    public void setHtml(String html) {
        this.html = html;
    }

    @Basic
    @Column(name = "create_time", nullable = true)
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "update_time", nullable = true)
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }


    @ManyToOne
    @JoinColumn(name = "capture_url", referencedColumnName = "id")
    public CaptureWebsiteModel getCaptureWebsiteByCaptureUrl() {
        return captureWebsiteByCaptureUrl;
    }

    public void setCaptureWebsiteByCaptureUrl(CaptureWebsiteModel captureWebsiteByCaptureUrl) {
        this.captureWebsiteByCaptureUrl = captureWebsiteByCaptureUrl;
    }


    @ManyToOne
    @JoinColumn(name = "air_line", referencedColumnName = "id")
    public AirLineModel getAirLineByAirLine() {
        return airLineByAirLine;
    }

    public void setAirLineByAirLine(AirLineModel airLineByAirLine) {
        this.airLineByAirLine = airLineByAirLine;
    }


    @ManyToOne
    @JoinColumn(name = "capture_mark_id", referencedColumnName = "id")
    public CaptureMarkModel getCaptureMarkByCaptureMarkId() {
        return captureMarkByCaptureMarkId;
    }

    public void setCaptureMarkByCaptureMarkId(CaptureMarkModel captureMarkByCaptureMarkId) {
        this.captureMarkByCaptureMarkId = captureMarkByCaptureMarkId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        OriginDataModel model = (OriginDataModel) o;

        if (id != null ? !id.equals(model.id) : model.id != null) return false;
        if (html != null ? !html.equals(model.html) : model.html != null) return false;
        if (createTime != null ? !createTime.equals(model.createTime) : model.createTime != null) return false;
        if (updateTime != null ? !updateTime.equals(model.updateTime) : model.updateTime != null) return false;
        if (captureWebsiteByCaptureUrl != null ? !captureWebsiteByCaptureUrl.equals(model.captureWebsiteByCaptureUrl) : model.captureWebsiteByCaptureUrl != null)
            return false;
        if (airLineByAirLine != null ? !airLineByAirLine.equals(model.airLineByAirLine) : model.airLineByAirLine != null)
            return false;
        return captureMarkByCaptureMarkId != null ? captureMarkByCaptureMarkId.equals(model.captureMarkByCaptureMarkId) : model.captureMarkByCaptureMarkId == null;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (html != null ? html.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
        result = 31 * result + (captureWebsiteByCaptureUrl != null ? captureWebsiteByCaptureUrl.hashCode() : 0);
        result = 31 * result + (airLineByAirLine != null ? airLineByAirLine.hashCode() : 0);
        result = 31 * result + (captureMarkByCaptureMarkId != null ? captureMarkByCaptureMarkId.hashCode() : 0);
        return result;
    }
}
